<?php

/** 
 * 友盟控制器
 * @property User_um_info_mdl $umInfo
 * @property UmPush $umPush
 */
class Umeng extends MY_Controller {
	function __construct() {
		parent::__construct ();
		$this->load->model ( 'User_um_info_mdl', 'umInfo' );
	}
	
	/**
	 * 纪录友盟device_token接口
	 */
	public function device_token() {
		$userID = ( int ) $this->input->post_get ( 'userID', TRUE );
		$token = $this->input->post_get ( 'token', TRUE );
		$system = $this->input->post_get ( 'system', TRUE );
		$token = trim ( $token );
		$system = trim ( $system );
		if ($userID < 0 OR empty ( $token ) OR ! in_array ( $system, array ( 'ios', 'android' ) )) {
			$this->apiOutput->errorInput ();
		}
		
		$res = $this->umInfo->saveDeviceToken ( $userID, $token, $system );
		if ($res) {
			$this->apiOutput->out ();
		} else {
			$this->apiOutput->errorSystem ();
		}
	}
}

